package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.statistics.GoodsStatisticsVo;
import com.cskaoyan.bean.vo.statistics.OrderStatisticsVo;
import com.cskaoyan.bean.vo.statistics.UserStatisticsVo;
import com.cskaoyan.service.admin.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Yan Dexuan
 * @since 2022/06/26 13:41
 */

@RestController
@RequestMapping("admin/stat")
public class StatisticsController {

    @Autowired
    StatisticsService statisticsService;

    /**
     * 用户统计功能，显示用户增长数量，最后登录日期。
     * @return com.cskaoyan.bean.vo.BaseRespVo
     * @author Yan Dexuan
     * @since 2022/06/26 16:08
     */
    @RequestMapping("user")
    public BaseRespVo showUser(){

        UserStatisticsVo user = statisticsService.showUser();
        return BaseRespVo.ok(user);

    }

    /**
     * 订单统计功能，显示订单量，下单用户，订单总额以及客单价。
     * @return com.cskaoyan.bean.vo.BaseRespVo
     * @author Yan Dexuan
     * @since 2022/06/26 20:13
     */
    @RequestMapping("order")
    public BaseRespVo showOrder(){

        OrderStatisticsVo order = statisticsService.showOrder();
        return BaseRespVo.ok(order);

    }

    /**
     * 商品统计功能，显示订单量，下单货品数量以及下单货品总额。
     * @return com.cskaoyan.bean.vo.BaseRespVo
     * @author Yan Dexuan
     * @since 2022/06/26 20:14 
     */
    @RequestMapping("goods")
    public BaseRespVo showGoods(){

        GoodsStatisticsVo goods = statisticsService.showGoods();
        return BaseRespVo.ok(goods);

    }

}
